package com.ruimei.config;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.support.http.StatViewServlet;
import com.alibaba.druid.support.http.WebStatFilter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.Filter;
import javax.sql.DataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DruidConfig
{
  @ConfigurationProperties(prefix="spring.datasource")
  @Bean
  public DataSource druice()
  {
    return new DruidDataSource();
  }
  
  @Bean
  public ServletRegistrationBean<StatViewServlet> statViewServlet()
  {
    ServletRegistrationBean<StatViewServlet> bean = new ServletRegistrationBean(new StatViewServlet(), new String[] { "/druid/*" });
    
    Map<String, String> initParam = new HashMap();
    
    initParam.put("loginUsername", "admin");
    initParam.put("loginPassword", "admin123");
    
    initParam.put("allow", "");
    
    initParam.put("deny", "192.168.10.1");
    
    bean.setInitParameters(initParam);
    
    return bean;
  }
  
  @Bean
  public FilterRegistrationBean<Filter> filter()
  {
    FilterRegistrationBean<Filter> bean = new FilterRegistrationBean();
    bean.setFilter(new WebStatFilter());
    
    Map<String, String> initParam = new HashMap();
    
    initParam.put("exclusions", "*.js,*.css,/druid/*");
    
    bean.setUrlPatterns(Arrays.asList(new String[] { "/*" }));
    return bean;
  }
}


/* Location:              E:\360MoveData\Users\admin\Desktop\teacher_wap-0.0.1-SNAPSHOT.jar!\BOOT-INF\classes\com\ruimei\config\DruidConfig.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       0.7.1
 */